import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)
const store = new Vuex.Store({
	state: {
		//全局变量
		userInfo: {},
		isLogin: true
	},
	//同步修改state中值的方法
	mutations: {
		//改变登录状态
		login(state,provider) {
			state.isLogin = false
			state.userInfo = provider
			uni.setStorage({
				key: 'userInfo',
				data: provider
			})
		},
		logout(state) {
			state.isLogin = true
			state.userInfo = {}
			uni.removeStorage({
				key: 'userInfo'
			})
		}
	}
})
export default store